<?php
$baseUrl = Yii::app()->baseUrl; 
$cs = Yii::app()->getClientScript();
//$cs->registerCssFile($baseUrl.'/css/gridviewjquery-ui.css');


$cs->registerCssFile($baseUrl.'/js/Treeview/src/skin/ui.dynatree.css');
$cs->registerScriptFile($baseUrl.'/js/Treeview/jquery/jquery.js');
$cs->registerScriptFile($baseUrl.'/js/Treeview/jquery/jquery-ui.custom.js');
$cs->registerScriptFile($baseUrl.'/js/Treeview/jquery/jquery.cookie.js');
$cs->registerScriptFile($baseUrl.'/js/Treeview/src/jquery.dynatree.js');
$cs->registerScriptFile($baseUrl.'/js/pagging.js');
$cs->registerScriptFile($baseUrl.'/js/settings.js');
$cs->registerCssFile($baseUrl.'/css/settings.css');


?>


<div id="wrapper">
<div id="sideNav_wrapper">
<div id="sideNav">

<h1>Settings</h1>
<div id="leftmenu" class="section">
<ul id="settings" class="tabs">
	<li><a href="#account" class="tabitem">Account</a></li>
	<li><a href="#preferences" class="tabitem">Preferences</a></li>
	<li><a id ="category" href="#category" class="tabitem">Category of Expense</a></li>
	<li><a id="userManagement" href="#userManagement" class="tabitem">User management</a></li>
	<li><a href="#groupManagement" class="tabitem">Group management</a></li>
	<li><a href="#customer" class="tabitem">Customer</a></li>
	<li><a href="#currency" class="tabitem">Currency</a></li>
	<li><a href="#exchangeRate" class="tabitem">Exchange rate</a></li>
	<li><a href="#unitMeasure" class="tabitem">Unit of Measure</a></li>
	<li><a href="#unitConvert" class="tabitem">Unit Convert</a></li>
	<li><a href="#department" class="tabitem">Department</a></li>
	<li><a href="#company" class="tabitem">Company</a></li>

</ul>
</div>

<div class="section last" id="howDoI">
<h3>How do I Expense System</h3>
<p></p>
<ul>
	<li>How do I <a href="#settings#merge"
		title="Merge two Expensify accounts in to one" target="_blank">merge
	two accounts?</a></li>
	<li>How do I <a href="#currency"
		title="Set the currency of your expenses" target="_blank">set my
	default currency?</a></li>
</ul>
<p></p>
<a href="#" title="Get help with using the Expensify app"
	target="_blank">More help...</a></div>

</div>
</div>

<div id="content_wrapper">
	
<!-- Account Tab -->
<div id="accountPanes" class="panes">
 Account
</div>
<!-- Preferences tab-->
<div id="preferencesPanes" class="panes">
preferencesPanes
</div>
<!-- End Preferences tab -->

<!-- Category of expense tab -->
<div id="categoryPanes" class="panes">
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'expensecategory-form',
	'enableAjaxValidation'=>true,
    'action'=>$this->createUrl('user/create'),
    'enableClientValidation'=>true,
	'htmlOptions'=>array(
                          'class'=>'form long-labels',
                        )
)); ?>
<h2>Expense category
       <a target="_blank" href="#" class="help_link qtip" id="userCreateNew"></a>
   </h2>
  
	<ol>
	    <li>
			<?php echo $form->labelEx($expenseCategoryModel,'Category Name'); ?>
			<?php echo $form->textField($expenseCategoryModel,'CategoryName',array('size'=>60,'maxlength'=>255,'class'=>'expensecategory_field')); ?>
			<?php echo $form->error($expenseCategoryModel,'CategoryName'); ?>
        </li>
		<li>
			<?php echo $form->labelEx($expenseCategoryModel,'Description'); ?>
			<?php echo $form->textField($expenseCategoryModel,'Description',array('size'=>60,'maxlength'=>255,'class'=>'user_field')); ?>
			<?php echo $form->error($expenseCategoryModel,'Description'); ?>
			
        </li>
        <li>
			<?php echo $form->labelEx($expenseCategoryModel,'Enable'); ?>
			<?php echo $form->checkBox($expenseCategoryModel,'Enable'); ?>
			<?php echo $form->error($expenseCategoryModel,'Enable'); ?>
			
        </li>
        <li>
			 <?php echo CHtml::ajaxSubmitButton('Save',CHtml::normalizeUrl(array('expensecategory/create','render'=>true)),
                 array(
                     'dataType'=>'json',
                     'type'=>'post',
                     'success'=>'function(data) {
                     	  $(".errorMessage").hide();
  						 $(".expensecategory_field").css("border-color",""); 
                         $("#AjaxLoader").hide();  
						 $("#sucess").hide();  
                        if(data.status=="success"){
                          $("#formResult").html("form submitted successfully.");
						 $("#sucess").show("slow");  
						 $("#sucess").hide("slow");
                         $("#expensecategory-form")[0].reset();
					
      					 var row =data.newRowHtml,
						 $row = $(row),
						 resort = true;
						  $("#categoryPanes table").prepend($row)
						      .trigger("addRows", [$row, resort]);
                             
                        }
                         else{
                        
                        $.each(data, function(key, val) {
                        $("#expensecategory-form #"+key+"").css("border-color","red");
                        $("#expensecategory-form #"+key+"_em_").text(val).css("color","red");                                                    
                        $("#expensecategory-form #"+key+"_em_").show();
                        });
                        }       
                    }',                    
                     'beforeSend'=>'function(){                        
                           $("#AjaxLoader").show();
                      }'
                     ),array('id'=>'expensecategorybtn','style'=>'width:100px;height: 40px;')); ?>
                     <img id="AjaxLoader" style="display: none" src="<?php echo Yii::app()->request->baseUrl; ?>/images/spinner_2x.gif"></img>
                     <img  id="sucess" style="display: none" src="<?php echo Yii::app()->request->baseUrl; ?>/images/bg_check.png"></img>
 					
 					<div class="errorMessage" id="formResult">
 						
 					</div>


        </li>
</ol>
<?php $this->endWidget(); ?>
<div id="expensecategory-grid"></div>
<!-- End Category of expense tab-->

<!-- User management -->
<div id="userManagementPanes" class="panes">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'user-form',
	'enableAjaxValidation'=>true,
    'action'=>$this->createUrl('user/create'),
    'enableClientValidation'=>true,
	'htmlOptions'=>array(
                          'class'=>'form long-labels',
                        )
)); ?>

   <h2>New User
       <a target="_blank" href="#" class="help_link qtip" id="userCreateNew"></a>
   </h2>
  
	<ol>

	     <li>
			<h4>User Information</h4>
        </li>
	    <li>
			<?php echo $form->labelEx($userModel,'FullName'); ?>
			<?php echo $form->textField($userModel,'FullName',array('size'=>60,'maxlength'=>255,'class'=>'user_field')); ?>
			<?php echo $form->error($userModel,'FullName'); ?>
        </li>
		<li>
			<?php echo $form->labelEx($userModel,'Email'); ?>
			<?php echo $form->textField($userModel,'Email',array('size'=>60,'maxlength'=>255,'class'=>'user_field')); ?>
			<?php echo $form->error($userModel,'Email'); ?>
			
        </li>
        <li>
			<?php echo $form->labelEx($userModel,'Password'); ?>
			<?php echo $form->passwordField($userModel,'Password',array('size'=>50,'maxlength'=>50,'class'=>'user_field')); ?>
			<?php echo $form->error($userModel,'Password'); ?>
			
        </li>
         <li>
        	<?php echo $form->labelEx($userModel,'Group'); ?>
        	<?php echo $form->dropDownList($userModel,'GroupId',CHtml::listData(Group::model()->findAll(), 'GroupId', 'GroupName'),
        									array('empty'=>'Select Group',
        									      'id'=>'Group',
												  
											));?>
			<?php echo $form->error($userModel,'GroupId'); ?>
			
        </li>
        <li>
        	<?php echo $form->labelEx($userModel,'Company'); ?>
        	<?php echo $form->dropDownList($userModel,'CompanyId',CHtml::listData(Company::model()->findAll(), 'CompanyId', 'CompanyName'),
        									array('empty'=>'Select Company',
        									      'id'=>'company',
        									      'ajax' => array(
                                                   'type' => 'POST',
                                                   'url' => CController::createUrl('settings/loaddepartment'),
                                                   'update' => '#department',
                                                   'data' => array('company'=>'js:this.value'))
												  
											));?>
			<?php echo $form->error($userModel,'CompanyId'); ?>
			
        </li>
        <li>
        	<?php echo $form->labelEx($userModel,'Department'); ?>
			<?php echo $form->dropDownList($userModel,'DepartmenId',CHtml::listData(array(), 'DepartmenId', 'DepartmentName'),
									array(
										'empty'=>'Select company first',
										'id'=>'department'
									)); ?>
		   <?php echo $form->error($userModel,'DepartmentId'); ?>
			
			
        </li>
        <li>
			<?php echo $form->labelEx($userModel,'Superior Email'); ?>
			<?php echo $form->textField($userModel,'SuperiorEmail',array('size'=>60,'maxlength'=>255)); ?>
			<?php echo $form->error($userModel,'SuperiorEmail'); ?>
			
        </li>
         <li>
			<?php echo $form->labelEx($userModel,'Create At'); ?>
			<?php echo $form->textField($userModel,'CreateAt',array('style'=>'width: 168px;','value'=>date('Y-m-d H:i:s'))); ?>
			<?php echo $form->error($userModel,'CreateAt'); ?>
        </li>
         <li>
			<?php echo $form->labelEx($userModel,'Enable'); ?>
			<?php echo $form->checkBox($userModel,'Enable'); ?>
			<?php echo $form->error($userModel,'Enable'); ?>
        </li>
        <li>
			<h4>Permistion</h4>
        </li>
        <li>
			<div id="tree" style="width:522px;height: 350px;" name="selNodes">
			</div>
	        <?php echo $form->hiddenField($userModel,'Role',array('value'=>'','id'=>'roles')); ?>
        </li>
        
         <li>
            <br/>
			 <?php echo CHtml::ajaxSubmitButton('Save',CHtml::normalizeUrl(array('user/create','render'=>true)),
                 array(
                     'dataType'=>'json',
                     'type'=>'post',
                     'success'=>'function(data) {
                     	  $(".errorMessage").hide();
  						 $(".user_field").css("border-color",""); 
                         $("#AjaxLoader").hide();  
                        if(data.status=="success"){
                         $("#user-form #"+key+"").css("border-color","red");
                         $("#formResult").html("form submitted successfully.");
                         $("#user-form")[0].reset();
                        }
                         else{
                        
                        $.each(data, function(key, val) {
                        $("#user-form #"+key+"").css("border-color","red");
                        $("#user-form #"+key+"_em_").text(val).css("color","red");                                                    
                        $("#user-form #"+key+"_em_").show();
                        });
                        }       
                    }',                    
                     'beforeSend'=>'function(){                        
                           $("#AjaxLoader").show();
                      }'
                     ),array('id'=>'mybtn','style'=>'width:100px;height: 40px;')); ?>
                     <img id="AjaxLoader" style="display: none" src="<?php echo Yii::app()->request->baseUrl; ?>/images/spinner_2x.gif"></img>
 					<div class="errorMessage" id="formResult"></div>


        </li>
	</ol>
   
   

<?php $this->endWidget(); ?>



</div>
<!-- End User management -->

<!--Group management tab -->
<div id="groupManagementPanes" class="panes">
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'group-form',
	'enableAjaxValidation'=>true,
    'action'=>$this->createUrl('user/create'),
    'enableClientValidation'=>true,
	'htmlOptions'=>array(
                          'class'=>'form long-labels',
                        )
)); ?>
<h2>Group management
       <a target="_blank" href="#" class="help_link qtip" id="groupCreateNew"></a>
   </h2>
  
	<ol>
	    <li>
			<?php echo $form->labelEx($groupModel,'Group Name'); ?>
			<?php echo $form->textField($groupModel,'GroupName',array('size'=>60,'maxlength'=>255,'class'=>'user_field')); ?>
			<?php echo $form->error($groupModel,'GroupName'); ?>
        </li>
		<li>
			<?php echo $form->labelEx($groupModel,'Description'); ?>
			<?php echo $form->textField($groupModel,'Description',array('size'=>60,'maxlength'=>255,'class'=>'user_field')); ?>
			<?php echo $form->error($groupModel,'Description'); ?>
			
        </li>
        <li>
			<?php echo $form->labelEx($groupModel,'Enable'); ?>
			<?php echo $form->checkBox($groupModel,'Enable'); ?>
			<?php echo $form->error($groupModel,'Enable'); ?>
			
        </li>
        <li>
			 <?php echo CHtml::ajaxSubmitButton('Save',CHtml::normalizeUrl(array('user/create','render'=>true)),
                 array(
                     'dataType'=>'json',
                     'type'=>'post',
                     'success'=>'function(data) {
                     	  $(".errorMessage").hide();
  						 $(".user_field").css("border-color",""); 
                         $("#AjaxLoader").hide();  
                        if(data.status=="success"){
                         $("#user-form #"+key+"").css("border-color","red");
                         $("#formResult").html("form submitted successfully.");
                         $("#user-form")[0].reset();
                        }
                         else{
                        
                        $.each(data, function(key, val) {
                        $("#user-form #"+key+"").css("border-color","red");
                        $("#user-form #"+key+"_em_").text(val).css("color","red");                                                    
                        $("#user-form #"+key+"_em_").show();
                        });
                        }       
                    }',                    
                     'beforeSend'=>'function(){                        
                           $("#AjaxLoader").show();
                      }'
                     ),array('id'=>'mybtn','style'=>'width:100px;height: 40px;')); ?>
                     <img id="AjaxLoader" style="display: none" src="<?php echo Yii::app()->request->baseUrl; ?>/images/spinner_2x.gif"></img>
 					<div class="errorMessage" id="formResult"></div>


        </li>
</ol>
<?php $this->endWidget(); ?>


</div>
<!-- End Group management tab -->

<!-- Customer tab -->
<div id="customerPanes" class="panes">
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'customer-form',
	'enableAjaxValidation'=>true,
    'action'=>$this->createUrl('customer/create'),
    'enableClientValidation'=>true,
	'htmlOptions'=>array(
                          'class'=>'form long-labels',
                        )
)); ?>
<h2>Customer
       <a target="_blank" href="#" class="help_link qtip" id="userCreateNew"></a>
   </h2>
  
	<ol>
	    <li>
			<?php echo $form->labelEx($customerModel,'Customer Name'); ?>
			<?php echo $form->textField($customerModel,'CustomerName',array('size'=>60,'maxlength'=>255,'class'=>'user_field')); ?>
			<?php echo $form->error($customerModel,'CustomerName'); ?>
        </li>
		<li>
			<?php echo $form->labelEx($customerModel,'Mobile'); ?>
			<?php echo $form->textField($customerModel,'Mobile',array('size'=>60,'maxlength'=>255,'class'=>'user_field')); ?>
			<?php echo $form->error($customerModel,'Mobile'); ?>
			
        </li>
		<li>
			<?php echo $form->labelEx($customerModel,'Email'); ?>
			<?php echo $form->textField($customerModel,'Email',array('size'=>60,'maxlength'=>255,'class'=>'user_field')); ?>
			<?php echo $form->error($customerModel,'Email'); ?>
			
        </li>
		<li>
			<?php echo $form->labelEx($customerModel,'Address1'); ?>
			<?php echo $form->textField($customerModel,'Address1',array('size'=>60,'maxlength'=>255,'class'=>'user_field')); ?>
			<?php echo $form->error($customerModel,'Address1'); ?>
			
        </li>
        <li>
			<?php echo $form->labelEx($customerModel,'Address2'); ?>
			<?php echo $form->textField($customerModel,'Address2',array('size'=>60,'maxlength'=>255,'class'=>'user_field')); ?>
			<?php echo $form->error($customerModel,'Address2'); ?>
			
        </li> 
        <li>
        	<?php echo $form->labelEx($customerModel,'Company'); ?>
        	<?php echo $form->dropDownList($customerModel,'CompanyId',CHtml::listData(Company::model()->findAll(), 'CompanyId', 'CompanyName'),
        									array('empty'=>'Select Company',
        									      'id'=>'company',
        									      'ajax' => array(
                                                   'type' => 'POST',
                                                   'url' => CController::createUrl('settings/loaddepartment'),
                                                   'update' => '#department',
                                                   'data' => array('company'=>'js:this.value'))
												  
											));?>
			<?php echo $form->error($customerModel,'CompanyId'); ?>
			
        </li>                 
        <li>
			<?php echo $form->labelEx($customerModel,'Enable'); ?>
			<?php echo $form->checkBox($customerModel,'Enable'); ?>
			<?php echo $form->error($customerModel,'Enable'); ?>
			
        </li>
        <li>
			 <?php echo CHtml::ajaxSubmitButton('Save',CHtml::normalizeUrl(array('user/create','render'=>true)),
                 array(
                     'dataType'=>'json',
                     'type'=>'post',
                     'success'=>'function(data) {
                     	  $(".errorMessage").hide();
  						 $(".user_field").css("border-color",""); 
                         $("#AjaxLoader").hide();  
                        if(data.status=="success"){
                         $("#user-form #"+key+"").css("border-color","red");
                         $("#formResult").html("form submitted successfully.");
                         $("#user-form")[0].reset();
                        }
                         else{
                        
                        $.each(data, function(key, val) {
                        $("#user-form #"+key+"").css("border-color","red");
                        $("#user-form #"+key+"_em_").text(val).css("color","red");                                                    
                        $("#user-form #"+key+"_em_").show();
                        });
                        }       
                    }',                    
                     'beforeSend'=>'function(){                        
                           $("#AjaxLoader").show();
                      }'
                     ),array('id'=>'mybtn','style'=>'width:100px;height: 40px;')); ?>
                     <img id="AjaxLoader" style="display: none" src="<?php echo Yii::app()->request->baseUrl; ?>/images/spinner_2x.gif"></img>
 					<div class="errorMessage" id="formResult"></div>


        </li>
</ol>
<?php $this->endWidget(); ?>


?>

</div>
<!-- End Customer tab -->

<!-- Currency tab -->
<div id="currencyPanes" class="panes">
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'currency-form',
	'enableAjaxValidation'=>true,
    'action'=>$this->createUrl('currency/create'),
    'enableClientValidation'=>true,
	'htmlOptions'=>array(
                          'class'=>'form long-labels',
                        )
)); ?>
<h2>Currency
       <a target="_blank" href="#" class="help_link qtip" id="currencyCreateNew"></a>
   </h2>
  
	<ol>
	    <li>
			<?php echo $form->labelEx($currencyModel,'Currency Name'); ?>
			<?php echo $form->textField($currencyModel,'CurrencyName',array('size'=>60,'maxlength'=>255,'class'=>'user_field')); ?>
			<?php echo $form->error($currencyModel,'CurrencyName'); ?>
        </li>
       <li>
			<?php echo $form->labelEx($currencyModel,'Symbol'); ?>
			<?php echo $form->textField($currencyModel,'Symbol',array('size'=>60,'maxlength'=>255,'class'=>'user_field')); ?>
			<?php echo $form->error($currencyModel,'Symbol'); ?>
        </li>
		<li>
			<?php echo $form->labelEx($currencyModel,'Description'); ?>
			<?php echo $form->textField($currencyModel,'Description',array('size'=>60,'maxlength'=>255,'class'=>'user_field')); ?>
			<?php echo $form->error($currencyModel,'Description'); ?>
			
        </li>
        <li>
			<?php echo $form->labelEx($currencyModel,'Enable'); ?>
			<?php echo $form->checkBox($currencyModel,'Enable'); ?>
			<?php echo $form->error($currencyModel,'Enable'); ?>
			
        </li>
        <li>
			 <?php echo CHtml::ajaxSubmitButton('Save',CHtml::normalizeUrl(array('user/create','render'=>true)),
                 array(
                     'dataType'=>'json',
                     'type'=>'post',
                     'success'=>'function(data) {
                     	  $(".errorMessage").hide();
  						 $(".user_field").css("border-color",""); 
                         $("#AjaxLoader").hide();  
                        if(data.status=="success"){
                         $("#user-form #"+key+"").css("border-color","red");
                         $("#formResult").html("form submitted successfully.");
                         $("#user-form")[0].reset();
                        }
                         else{
                        
                        $.each(data, function(key, val) {
                        $("#user-form #"+key+"").css("border-color","red");
                        $("#user-form #"+key+"_em_").text(val).css("color","red");                                                    
                        $("#user-form #"+key+"_em_").show();
                        });
                        }       
                    }',                    
                     'beforeSend'=>'function(){                        
                           $("#AjaxLoader").show();
                      }'
                     ),array('id'=>'mybtn','style'=>'width:100px;height: 40px;')); ?>
                     <img id="AjaxLoader" style="display: none" src="<?php echo Yii::app()->request->baseUrl; ?>/images/spinner_2x.gif"></img>
 					<div class="errorMessage" id="formResult"></div>


        </li>
</ol>
<?php $this->endWidget(); ?>

</div>
<!-- End Currency tab-->
<!-- Company tab-->
<div id="exchangeRatePanes" class="panes">
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'group-form',
	'enableAjaxValidation'=>true,
    'action'=>$this->createUrl('exchangerate/create'),
    'enableClientValidation'=>true,
	'htmlOptions'=>array(
                          'class'=>'form long-labels',
                        )
)); ?>
<h2>Exchange Rate
       <a target="_blank" href="#" class="help_link qtip" id="groupCreateNew"></a>
   </h2>
  
	<ol>
	    <li>
			<?php echo $form->labelEx($exchangeRateModel,'Currency'); ?>
			<?php echo $form->textField($exchangeRateModel,'CurrencyId',array('size'=>60,'maxlength'=>255,'class'=>'user_field')); ?>
			<?php echo $form->error($exchangeRateModel,'CurrencyId'); ?>
        </li>     
		<li>
			<?php echo $form->labelEx($exchangeRateModel,'Exchange Rate'); ?>
			<?php echo $form->textField($exchangeRateModel,'ExchangeRate',array('size'=>60,'maxlength'=>255,'class'=>'user_field')); ?>
			<?php echo $form->error($exchangeRateModel,'ExchangeRate'); ?>
			
        </li>
		<li>
			<?php echo $form->labelEx($exchangeRateModel,'On Date'); ?>
			<?php echo $form->textField($exchangeRateModel,'Ondate',array('size'=>60,'maxlength'=>255,'class'=>'user_field')); ?>
			<?php echo $form->error($exchangeRateModel,'Ondate'); ?>
			
        </li>
        <li>
			<?php echo $form->labelEx($exchangeRateModel,'Enable'); ?>
			<?php echo $form->checkBox($exchangeRateModel,'Enable'); ?>
			<?php echo $form->error($exchangeRateModel,'Enable'); ?>
			
        </li>
        <li>
			 <?php echo CHtml::ajaxSubmitButton('Save',CHtml::normalizeUrl(array('user/create','render'=>true)),
                 array(
                     'dataType'=>'json',
                     'type'=>'post',
                     'success'=>'function(data) {
                     	  $(".errorMessage").hide();
  						 $(".user_field").css("border-color",""); 
                         $("#AjaxLoader").hide();  
                        if(data.status=="success"){
                         $("#user-form #"+key+"").css("border-color","red");
                         $("#formResult").html("form submitted successfully.");
                         $("#user-form")[0].reset();
                        }
                         else{
                        
                        $.each(data, function(key, val) {
                        $("#user-form #"+key+"").css("border-color","red");
                        $("#user-form #"+key+"_em_").text(val).css("color","red");                                                    
                        $("#user-form #"+key+"_em_").show();
                        });
                        }       
                    }',                    
                     'beforeSend'=>'function(){                        
                           $("#AjaxLoader").show();
                      }'
                     ),array('id'=>'mybtn','style'=>'width:100px;height: 40px;')); ?>
                     <img id="AjaxLoader" style="display: none" src="<?php echo Yii::app()->request->baseUrl; ?>/images/spinner_2x.gif"></img>
 					<div class="errorMessage" id="formResult"></div>


        </li>
</ol>
<?php $this->endWidget(); ?>


</div>
<!-- Unit of Measure -->
<div id="unitMeasurePanes" class="panes">
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'group-form',
	'enableAjaxValidation'=>true,
    'action'=>$this->createUrl('unit/create'),
    'enableClientValidation'=>true,
	'htmlOptions'=>array(
                          'class'=>'form long-labels',
                        )
)); ?>
<h2>Unit of Measure
       <a target="_blank" href="#" class="help_link qtip" id="groupCreateNew"></a>
   </h2>
  
	<ol>
	    <li>
			<?php echo $form->labelEx($unitModel,'UnitName'); ?>
			<?php echo $form->textField($unitModel,'UnitName',array('size'=>60,'maxlength'=>255,'class'=>'user_field')); ?>
			<?php echo $form->error($unitModel,'UnitName'); ?>
        </li>
		<li>
			<?php echo $form->labelEx($unitModel,'Description'); ?>
			<?php echo $form->textField($unitModel,'Description',array('size'=>60,'maxlength'=>255,'class'=>'user_field')); ?>
			<?php echo $form->error($unitModel,'Description'); ?>
			
        </li>
        <li>
			<?php echo $form->labelEx($unitModel,'Enable'); ?>
			<?php echo $form->checkBox($unitModel,'Enable'); ?>
			<?php echo $form->error($unitModel,'Enable'); ?>
			
        </li>
        <li>
			 <?php echo CHtml::ajaxSubmitButton('Save',CHtml::normalizeUrl(array('user/create','render'=>true)),
                 array(
                     'dataType'=>'json',
                     'type'=>'post',
                     'success'=>'function(data) {
                     	  $(".errorMessage").hide();
  						 $(".user_field").css("border-color",""); 
                         $("#AjaxLoader").hide();  
                        if(data.status=="success"){
                         $("#user-form #"+key+"").css("border-color","red");
                         $("#formResult").html("form submitted successfully.");
                         $("#user-form")[0].reset();
                        }
                         else{
                        
                        $.each(data, function(key, val) {
                        $("#user-form #"+key+"").css("border-color","red");
                        $("#user-form #"+key+"_em_").text(val).css("color","red");                                                    
                        $("#user-form #"+key+"_em_").show();
                        });
                        }       
                    }',                    
                     'beforeSend'=>'function(){                        
                           $("#AjaxLoader").show();
                      }'
                     ),array('id'=>'mybtn','style'=>'width:100px;height: 40px;')); ?>
                     <img id="AjaxLoader" style="display: none" src="<?php echo Yii::app()->request->baseUrl; ?>/images/spinner_2x.gif"></img>
 					<div class="errorMessage" id="formResult"></div>


        </li>
</ol>
<?php $this->endWidget(); ?>

</div>
<div id="unitConvertPanes" class="panes">
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'unitconvert-form',
	'enableAjaxValidation'=>true,
    'action'=>$this->createUrl('unitconvert/create'),
    'enableClientValidation'=>true,
	'htmlOptions'=>array(
                          'class'=>'form long-labels',
                        )
)); ?>
<h2>Unit Convert
       <a target="_blank" href="#" class="help_link qtip" id="groupCreateNew"></a>
   </h2>
  
	<ol>
	    <li>
         <li>
        	<?php echo $form->labelEx($unitConvertModel,'From Unit'); ?>
        	<?php echo $form->dropDownList($unitConvertModel,'FromUnitId',CHtml::listData(Unit::model()->findAll(), 'UnitId', 'UnitName'),
        									array('empty'=>'Select Group',
        									      'id'=>'FromUnit',
												  
											));?>
			<?php echo $form->error($userModel,'FromUnitId'); ?>
			
        </li>
        </li>
		<li>
        	<?php echo $form->labelEx($unitConvertModel,'To Unit'); ?>
        	<?php echo $form->dropDownList($unitConvertModel,'ToUnitId',CHtml::listData(Unit::model()->findAll(), 'UnitId', 'UnitName'),
        									array('empty'=>'Select Group',
        									      'id'=>'ToUnit',
												  
											));?>
			<?php echo $form->error($userModel,'ToUnitId'); ?>
			
        </li>
 		<li>
			<?php echo $form->labelEx($unitConvertModel,'Value'); ?>
			<?php echo $form->textField($unitConvertModel,'Value',array('size'=>60,'maxlength'=>255,'class'=>'user_field')); ?>
			<?php echo $form->error($unitConvertModel,'Value'); ?>
        </li>        
        <li>
			<?php echo $form->labelEx($unitConvertModel,'Enabled'); ?>
			<?php echo $form->checkBox($unitConvertModel,'Enabled'); ?>
			<?php echo $form->error($unitConvertModel,'Enabled'); ?>
			
        </li>
        <li>
			 <?php echo CHtml::ajaxSubmitButton('Save',CHtml::normalizeUrl(array('unitconvert/create','render'=>true)),
                 array(
                     'dataType'=>'json',
                     'type'=>'post',
                     'success'=>'function(data) {
                     	  $(".errorMessage").hide();
  						 $(".user_field").css("border-color",""); 
                         $("#AjaxLoader").hide();  
                        if(data.status=="success"){
                         $("#user-form #"+key+"").css("border-color","red");
                         $("#formResult").html("form submitted successfully.");
                         $("#user-form")[0].reset();
                        }
                         else{
                        
                        $.each(data, function(key, val) {
                        $("#user-form #"+key+"").css("border-color","red");
                        $("#user-form #"+key+"_em_").text(val).css("color","red");                                                    
                        $("#user-form #"+key+"_em_").show();
                        });
                        }       
                    }',                    
                     'beforeSend'=>'function(){                        
                           $("#AjaxLoader").show();
                      }'
                     ),array('id'=>'mybtn','style'=>'width:100px;height: 40px;')); ?>
                     <img id="AjaxLoader" style="display: none" src="<?php echo Yii::app()->request->baseUrl; ?>/images/spinner_2x.gif"></img>
 					<div class="errorMessage" id="formResult"></div>


        </li>
</ol>
<?php $this->endWidget(); ?>


</div>
<!-- Department tab-->
<div id="departmentPanes" class="panes">
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'department-form',
	'enableAjaxValidation'=>true,
    'action'=>$this->createUrl('unitconvert/create'),
    'enableClientValidation'=>true,
	'htmlOptions'=>array(
                          'class'=>'form long-labels',
                        )
)); ?>
<h2>Department
       <a target="_blank" href="#" class="help_link qtip" id="groupCreateNew"></a>
   </h2>
  
	<ol>
	    <li>
			<?php echo $form->labelEx($departmentModel,'Department Name'); ?>
			<?php echo $form->textField($departmentModel,'DepartmentName',array('size'=>60,'maxlength'=>255,'class'=>'user_field')); ?>
			<?php echo $form->error($departmentModel,'DepartmentName'); ?>
        </li>
		<li>
        	<?php echo $form->labelEx($departmentModel,'Company'); ?>
        	<?php echo $form->dropDownList($departmentModel,'CompanyId',CHtml::listData(Company::model()->findAll(), 'CompanyId', 'CompanyName'),
        									array('empty'=>'Select Company',
        									      'id'=>'company',
        									      'ajax' => array(
                                                   'type' => 'POST',
                                                   'url' => CController::createUrl('department/loaddepartment'),
                                                   'update' => '#department',
                                                   'data' => array('company'=>'js:this.value'))
												  
											));?>
			<?php echo $form->error($departmentModel,'CompanyId'); ?>
			
        </li>     
		<li>
        	<?php echo $form->labelEx($departmentModel,'Parent Department'); ?>
			<?php echo $form->dropDownList($departmentModel,'DepartmentId',CHtml::listData(Department::model()->findAll(), 'DepartmenId', 'DepartmentName'),
									array(
										'empty'=>'Select company first',
										'id'=>'department'
									)); ?>
		   <?php echo $form->error($departmentModel,'DepartmentId'); ?>
			
			
        </li>            
        <li>
			<?php echo $form->labelEx($departmentModel,'Enable'); ?>
			<?php echo $form->checkBox($departmentModel,'Enable'); ?>
			<?php echo $form->error($departmentModel,'Enable'); ?>
			
        </li>
        <li>
			 <?php echo CHtml::ajaxSubmitButton('Save',CHtml::normalizeUrl(array('user/create','render'=>true)),
                 array(
                     'dataType'=>'json',
                     'type'=>'post',
                     'success'=>'function(data) {
                     	  $(".errorMessage").hide();
  						 $(".user_field").css("border-color",""); 
                         $("#AjaxLoader").hide();  
                        if(data.status=="success"){
                         $("#user-form #"+key+"").css("border-color","red");
                         $("#formResult").html("form submitted successfully.");
                         $("#user-form")[0].reset();
                        }
                         else{
                        
                        $.each(data, function(key, val) {
                        $("#user-form #"+key+"").css("border-color","red");
                        $("#user-form #"+key+"_em_").text(val).css("color","red");                                                    
                        $("#user-form #"+key+"_em_").show();
                        });
                        }       
                    }',                    
                     'beforeSend'=>'function(){                        
                           $("#AjaxLoader").show();
                      }'
                     ),array('id'=>'mybtn','style'=>'width:100px;height: 40px;')); ?>
                     <img id="AjaxLoader" style="display: none" src="<?php echo Yii::app()->request->baseUrl; ?>/images/spinner_2x.gif"></img>
 					<div class="errorMessage" id="formResult"></div>


        </li>
</ol>
<?php $this->endWidget(); ?>

</div>
<!-- Company tab-->
<div id="companyPanes" class="panes">
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'company-form',
	'enableAjaxValidation'=>true,
    'action'=>$this->createUrl('company/create'),
    'enableClientValidation'=>true,
	'htmlOptions'=>array(
                          'class'=>'form long-labels',
                        )
)); ?>
<h2>Company
       <a target="_blank" href="#" class="help_link qtip" id="companyCreateNew"></a>
   </h2>
  
	<ol>
	    <li>
			<?php echo $form->labelEx($companyModel,'Company Name'); ?>
			<?php echo $form->textField($companyModel,'CompanyName',array('size'=>60,'maxlength'=>255,'class'=>'user_field')); ?>
			<?php echo $form->error($companyModel,'CompanyName'); ?>
        </li>
		<li>
			<?php echo $form->labelEx($companyModel,'Mobile'); ?>
			<?php echo $form->textField($companyModel,'Mobile',array('size'=>60,'maxlength'=>255,'class'=>'user_field')); ?>
			<?php echo $form->error($companyModel,'Mobile'); ?>
			
        </li>
		<li>
			<?php echo $form->labelEx($companyModel,'Email'); ?>
			<?php echo $form->textField($companyModel,'Email',array('size'=>60,'maxlength'=>255,'class'=>'user_field')); ?>
			<?php echo $form->error($companyModel,'Email'); ?>
			
        </li>
		<li>
			<?php echo $form->labelEx($companyModel,'Address1'); ?>
			<?php echo $form->textField($companyModel,'Address1',array('size'=>60,'maxlength'=>255,'class'=>'user_field')); ?>
			<?php echo $form->error($companyModel,'Address1'); ?>
			
        </li>
        <li>
			<?php echo $form->labelEx($companyModel,'Address2'); ?>
			<?php echo $form->textField($companyModel,'Address2',array('size'=>60,'maxlength'=>255,'class'=>'user_field')); ?>
			<?php echo $form->error($companyModel,'Address2'); ?>
			
        </li> 
                  
        <li>
			<?php echo $form->labelEx($companyModel,'Enable'); ?>
			<?php echo $form->checkBox($companyModel,'Enable'); ?>
			<?php echo $form->error($companyModel,'Enable'); ?>
			
        </li>
        <li>
			 <?php echo CHtml::ajaxSubmitButton('Save',CHtml::normalizeUrl(array('user/create','render'=>true)),
                 array(
                     'dataType'=>'json',
                     'type'=>'post',
                     'success'=>'function(data) {
                     	  $(".errorMessage").hide();
  						 $(".user_field").css("border-color",""); 
                         $("#AjaxLoader").hide();  
                        if(data.status=="success"){
                         $("#user-form #"+key+"").css("border-color","red");
                         $("#formResult").html("form submitted successfully.");
                         $("#user-form")[0].reset();
                        }
                         else{
                        
                        $.each(data, function(key, val) {
                        $("#user-form #"+key+"").css("border-color","red");
                        $("#user-form #"+key+"_em_").text(val).css("color","red");                                                    
                        $("#user-form #"+key+"_em_").show();
                        });
                        }       
                    }',                    
                     'beforeSend'=>'function(){                        
                           $("#AjaxLoader").show();
                      }'
                     ),array('id'=>'mybtn','style'=>'width:100px;height: 40px;')); ?>
                     <img id="AjaxLoader" style="display: none" src="<?php echo Yii::app()->request->baseUrl; ?>/images/spinner_2x.gif"></img>
 					<div class="errorMessage" id="formResult"></div>


        </li>
</ol>
<?php $this->endWidget(); ?>


</div>
<!-- End Department tab -->
</div>
<div class="pager tablesorter-pager">
    <input type="hidden" id="paggingAjaxUrl" name="paggingAjaxUrl"  value=""/>
    <input type="hidden" id="paddingDataShowPanel" name="paddingDataShowPanel"  value=""/>
	<img alt="First" class="first" src="<?php echo Yii::app()->baseUrl;?>/images/first.png">
	<img alt="Prev" class="prev" src="<?php echo Yii::app()->baseUrl;?>/images/prev.png">
	<span id="pagedisplay" class="pagedisplay"></span> <!-- this can be any element, including an input -->
	<img alt="Next" class="next" src="<?php echo Yii::app()->baseUrl;?>/images/next.png">
	<img alt="Last" class="last" src="<?php echo Yii::app()->baseUrl;?>/images/last.png">
	<select title="Select page size" class="pagesize" id="pageSize">
		<option value="10">10</option>
		<option value="20">20</option>
		<option value="30">30</option>
		<option value="40">40</option>		
	</select>
	<select title="Select page number" class="gotoPage" id="gotoPage">
	</select>
</div>
</div>



